import PyQt5

# import Windows  # 需要运行的.py文件名
from Windows import *
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog
from PyQt5 import QtWidgets


class SettingEdit(Ui_Form, QDialog):
    def __init__(self, parent=None):
        super(SettingEdit, self).__init__(parent)
        self.setupUi(self)
        self.setting = {
            "ACLT": {},
            "HomeBrew": {},
            "Run": {}
        }

    def Write(self):
        self.ACLT()
        self.HomeBrew()
        # self.IfZulu()
        self.Run()
        self.out = str(self.setting)
        with open("setting.devtool","w") as f:
            f.write(self.out)
            f.close()
            sys.exit()
        print(self.out)

    def ACLT(self):
        # self.win = Windows.Ui_Form
        # self.ACLTEnter = self.win.checkBox()
        self.ACLTEnter = self.checkBox.isChecked()
        self.Xcode = self.checkBox_2.isChecked()
        if self.ACLTEnter:
            self.setting["ACLT"]["Command_Line_Tools"] = "install"
        if self.Xcode:
            # self.setting["ACLT"] = {
            #     "Xcode":"install"
            # }
            self.setting["ACLT"]["xcode"] = "install"
            # self.setting.update()

    def HomeBrew(self):
        self.BrewPath = self.checkBox_6.isChecked()
        self.SetHosts = self.checkBox_6.isChecked()
        self.BrewInstall = self.checkBox_7.isChecked()
        if self.BrewPath:
            self.setting["HomeBrew"]["PATH"] = "set"
        if self.SetHosts:
            self.setting["HomeBrew"]["Hosts"] = "set"
        if self.BrewInstall:
            self.setting["HomeBrew"]["Install"] = "install"

    def IfZulu(self):
        self.Zulu = self.checkBox_3.isChecked()
        if self.Zulu:
            self.checkBox_4.setEnabled(False)
            self.setting["Run"]["JDK"] = "Zulu"

    def BrewInstalled(self):
        pass

    def BrewNotInstall(self):
        pass
    #     if self.checkBox_7.isChecked() == False:
    #         self.checkBox_8.setEnabled(False)
    #         self.checkBox_9.setEnabled(False)

    def Run(self):
        self.JDK = self.checkBox_4.isChecked()
        self.MySql = self.checkBox_8.isChecked()
        self.redis = self.checkBox_9.isChecked()
        self.chrome = self.checkBox_10.isChecked()
        self.edge = self.checkBox_11.isChecked()
        self.pd = self.checkBox_12.isChecked()
        self.PdArch = self.comboBox.currentText()
        self.qemu = self.checkBox_13.isChecked()
        if self.JDK:
            self.setting["Run"]["JDK"] = "Java"
        if self.MySql:
            self.setting["Run"]["MySql"] = "install"
        if self.redis:
            self.setting["Run"]["Redis"] = "install"
        if self.chrome:
            self.setting["Run"]["Chrome"] = "install"
        if self.edge:
            self.setting["Run"]["Edge"] = "install"
        if self.pd:
            self.setting["Run"]["Parallels"] = "install"
            if self.PdArch == "Apple芯片":
                self.setting["Run"]["ParallelsArch"] = "arm"
            else:
                self.setting["Run"]["ParallelsArch"] = "X86_64"
        if self.qemu:
            self.setting["Run"]["QEMU"] = "install"


        # print(type(self.PdArch))


if __name__ == '__main__':
    # app = QApplication(sys.argv)  # 创建应用程序
    # mainwindow = QMainWindow()  # 创建主窗口
    #
    # ui = Windows.Ui_Form()  # 调用first中的主窗口
    #
    # ui.setupUi(mainwindow)  # 向主窗口添加控件
    # out = WriteSetting()
    # out.ACLT()
    # mainwindow.show()  # 显示窗口
    # sys.exit(app.exec_())  # 程序执行循环
    app = QtWidgets.QApplication(sys.argv)
    widget = SettingEdit()
    widget.show()
    WS = SettingEdit()

    print(WS.setting)

    sys.exit(app.exec_())
